package domain.entities;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Address entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "address", catalog = "bms")
public class Address implements java.io.Serializable {

	// Fields

	private Integer id;
	private String address;
	private String city;
	private String country;
	private String email;
	private String fax;
	private String phone;
	private String province;
	private String zipCode;
	private Set<LaboratorioCentral> laboratorioCentrals = new HashSet<LaboratorioCentral>(
			0);
	private Set<ComiteEtica> comiteEticas = new HashSet<ComiteEtica>(0);
	private Set<CentroAddress> centroAddresses = new HashSet<CentroAddress>(0);
	private Set<ComiteDocencia> comiteDocencias = new HashSet<ComiteDocencia>(0);
	private Set<Vendorcentral> vendorcentrals = new HashSet<Vendorcentral>(0);
	private Set<LaboratorioLocal> laboratorioLocals = new HashSet<LaboratorioLocal>(
			0);

	// Constructors

	/** default constructor */
	public Address() {
	}

	/** full constructor */
	public Address(String address, String city, String country, String email,
			String fax, String phone, String province, String zipCode,
			Set<LaboratorioCentral> laboratorioCentrals,
			Set<ComiteEtica> comiteEticas, Set<CentroAddress> centroAddresses,
			Set<ComiteDocencia> comiteDocencias,
			Set<Vendorcentral> vendorcentrals,
			Set<LaboratorioLocal> laboratorioLocals) {
		this.address = address;
		this.city = city;
		this.country = country;
		this.email = email;
		this.fax = fax;
		this.phone = phone;
		this.province = province;
		this.zipCode = zipCode;
		this.laboratorioCentrals = laboratorioCentrals;
		this.comiteEticas = comiteEticas;
		this.centroAddresses = centroAddresses;
		this.comiteDocencias = comiteDocencias;
		this.vendorcentrals = vendorcentrals;
		this.laboratorioLocals = laboratorioLocals;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "address")
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "city")
	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	@Column(name = "country")
	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	@Column(name = "email")
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "fax")
	public String getFax() {
		return this.fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	@Column(name = "phone")
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "province")
	public String getProvince() {
		return this.province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	@Column(name = "zipCode")
	public String getZipCode() {
		return this.zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "address")
	public Set<LaboratorioCentral> getLaboratorioCentrals() {
		return this.laboratorioCentrals;
	}

	public void setLaboratorioCentrals(
			Set<LaboratorioCentral> laboratorioCentrals) {
		this.laboratorioCentrals = laboratorioCentrals;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "address")
	public Set<ComiteEtica> getComiteEticas() {
		return this.comiteEticas;
	}

	public void setComiteEticas(Set<ComiteEtica> comiteEticas) {
		this.comiteEticas = comiteEticas;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "address")
	public Set<CentroAddress> getCentroAddresses() {
		return this.centroAddresses;
	}

    public void setCentroAddresses(Set<CentroAddress> centroAddresses) {
		this.centroAddresses = centroAddresses;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "address")
	public Set<ComiteDocencia> getComiteDocencias() {
		return this.comiteDocencias;
	}

	public void setComiteDocencias(Set<ComiteDocencia> comiteDocencias) {
		this.comiteDocencias = comiteDocencias;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "address")
	public Set<Vendorcentral> getVendorcentrals() {
		return this.vendorcentrals;
	}

	public void setVendorcentrals(Set<Vendorcentral> vendorcentrals) {
		this.vendorcentrals = vendorcentrals;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "addresses")
	public Set<LaboratorioLocal> getLaboratorioLocals() {
		return this.laboratorioLocals;
	}

	public void setLaboratorioLocals(Set<LaboratorioLocal> laboratorioLocals) {
		this.laboratorioLocals = laboratorioLocals;
	}

    @Override
    public boolean equals(Object obj) {
        Address otro = (Address)obj;
        return this.id.equals(otro.id);
    }
}